var imges = document.querySelectorAll(".userIcon>img");
var fontNum = document.getElementsByClassName("fontNum");
var font1 = document.getElementById("font1");
var text1 = document.getElementById("text1");
var out = document.getElementById("out");
var imgSrc;
var num1 = document.getElementById("num1");
var num;
var num2;
var num3;
function iconOnclick(e) {
	for (var i = 0; i < imges.length; i++) {
		imges[i].className = "";
	}
	e.className = "xuanzhong";
	imgSrc = e.src;

}
text1.onkeyup = function () {
	num = text1.value.length;
	num1.innerText = 150 - text1.value.length;
	num3 = 150 - text1.value.length;
	num2 = Math.abs(150 - text1.value.length);
	if (num3 <= 0) {
		font1.innerText = "";
		font1.innerText = "已超出";
		num1.innerText = num2;
	}
}
function play() {
	var userName = document.getElementById("userName").value.trim();
	var num4 = userName.length;
	if (num4 == 0 ) {
		alert("请输入用户名!\r\n您的用户名\r\n用户名不能为空，切不大于8个字符");
		return false;
	} else if ( num4 > 8 ) {
		alert("请输入有效用户名!\r\n您的用户名太长了！\r\n用户名不能为空，切不大于8个字符");
		return false;
	}else if (!imgSrc) {
		imgSrc = "img/2.gif";
	}else if (num == 0) {
		alert("请输入发表内容!");
		return false;
	}else if (num > 150) {
		alert("sorry!\r\n您输入的内容过长!");
		return false;
	}
	var div1 = document.createElement("div");
	div1.className = "min";
	out.appendChild(div1);
	var spanPhoto = document.createElement("span");
	spanPhoto.className = "photo";
	div1.appendChild(spanPhoto);
	var img = document.createElement("img");
	img.src = imgSrc;
	spanPhoto.appendChild(img);
	var spanShow = document.createElement("span");
	spanShow.className = "show";
	div1.appendChild(spanShow);
	var spanName = document.createElement("span");
	spanName.className = "user_name";
	spanShow.appendChild(spanName);
	spanName.innerText = userName + ":";
	var spanText = document.createElement("span");
	spanText.className = "userText";
	spanShow.appendChild(spanText);
	spanText.innerText = text1.value;
	var pTime = document.createElement("p");
	spanShow.appendChild(pTime);
	var myDate = new Date();
	var newMonth = myDate.getMonth() + 1;
	var newDate = myDate.getDate();
	var newHours = myDate.getHours();
	var newMinutes = myDate.getMinutes();
	pTime.innerText = newMonth + "月" + newDate + "号" + " " + newHours + "时" + newMinutes + "分";
	var delect =  document.createElement("span");
	delect.className = "delect";
	delect.innerText = "删除";
	spanShow.appendChild(delect);
	div1.onmouseover = function () {
		delect.style.visibility = 'visible';
	}
	div1.onmouseleave = function () {
		delect.style.visibility = 'hidden';
	}
	delect.onclick = function () {
		out.removeChild(div1);
	}
}

